package cn.tedu.submarine;

import javax.swing.*;

public class Coin extends SeaObject {
    public static int ONECOIN = 0;
    public static int TWOCOIN = 1;
    public int marker = ONECOIN;

    public Coin(int x, int y,int marker) {
        super(30, 30, x, y, 6,1);
        this.marker = marker;
    }

    public int getMarker(){
        return marker;
    }

    public void move() {}

    public void remove(Battleship ship) {
        if (getY() >= 190){
            setY(getY()-getSpeed());
        }

        if (ship.getX()<this.getX()){
            int num = (getX() - ship.getX())/getSpeed();
            int count = 0;
            if (count <= num){
                count++;
                setX(getX() - getSpeed());
            }
        }

        if (ship.getX()>this.getX()){
            int num = (ship.getX() - getX())/getSpeed();
            int count = 0;
            if (count <= num){
                count++;
                setX(getX() + getSpeed());
            }
        }
    }

    int index = 0;
    public ImageIcon getImage(){
        index++;
        if (index%2==0){
            return Images.coin[0];
        }else {
            return Images.coin[1];
        }
    }

    public int getCoin(){
        return 1;
    }
}
